// 主题模式
export const ThemeMode = {
  LIGHT: 'light',
  DARK: 'dark'
}

// 获取当前主题模式
export const getThemeMode = () => {
  return localStorage.getItem('theme') || ThemeMode.LIGHT
}

// 设置主题模式
export const setThemeMode = (mode) => {
  localStorage.setItem('theme', mode)
  if (mode === ThemeMode.DARK) {
    document.documentElement.classList.add('dark')
  } else {
    document.documentElement.classList.remove('dark')
  }
}

// 切换主题模式
export const toggleThemeMode = () => {
  const currentMode = getThemeMode()
  const newMode = currentMode === ThemeMode.LIGHT ? ThemeMode.DARK : ThemeMode.LIGHT
  setThemeMode(newMode)
  return newMode
}

// 初始化主题
export const initTheme = () => {
  const savedMode = getThemeMode()
  setThemeMode(savedMode)
} 